#include "wc3observer.h"
#include "Extern_global_Variable.h"

procedure TObserver::Subscribe(Dword EventId, Dword PassedEventId,
	PObserver Listener)
{
	__asm
	{
		mov ecx, this
	}
	(*PObserver_VMT(vtable)).Subscribe(EventId, PassedEventId, *Listener);
}

procedure TObserver::Subscribe(Dword EventId, PObserver Listener)
{
	Subscribe(EventId, EventId, Listener);
}

procedure TObserver::Unsubscribe(Dword EventId, PObserver Listener)
{
	__asm
	{
		mov ecx, this
	}
	_CObserver_Unsubscribe(EventId, Listener);
}

Boolean TObserver::Notify(TEvent Event)
{
	__asm
	{
		mov ecx, this
	}
	return (*PObserver_VMT(vtable)).Notify(Event);
}

Boolean TObserver::Emit(TEvent Event)
{
	__asm
	{
		mov ecx, this
	}
	return (*PObserver_VMT(vtable)).PostEvent(Event);
}

procedure wc3observer_OnInit()
{
	Pointer(_CObserver_Unsubscribe) = Pointer(GameDll + 0x62A570);
}

void wc3observer_main()
{
	wc3main_SubscribeOnInit(&wc3observer_OnInit);
}
